<?php
	include_once("adb.php");
	
	class vaccines extends adb{
		function vaccines(){
			adb::adb();
		}
		/**
		*query all vaccines in the table and store the dataset in $this->result	
		*@return if successful true else false
		*/
		
		function get_all_vaccines(){
			$query="select vaccine_id,vaccine_name,schedule from vaccines";
			return $this->query($query);
		}
		
		function add_vaccine($vaccine_name,$schedule,$url){
			//write the SQL query and call $this->query()
			$query="insert into vaccines set vaccine_name='$vaccine_name', schedule=$schedule,vaccine_url='$url'";
			return $this->query($query);
		}
		/**
		*updates the record identified by id 
		*/
		function update_vaccine($vaccine_id,$vaccine_name,$schedule, $url){
			$query="update vaccines set vaccine_name='$vaccine_name',
						schedule=$schedule,vaccine_url='$url' where 
							vaccine_id=$vid";
			if(!$this->query($query)){
				return false;
			}
			return true;
		}
		
		function delete_vaccine($vaccine_id){
		
		}
		
		function get_vaccine($id){
			$query="select * from vaccines where vaccine_id=$id";
			if(!$this->query($query)){
				return false;
			}
			return $this->fetch();
		}
	}
	
	//call methods here to test
	/*$obj=new vaccines();
	if(!$obj->get_all_vaccines()){
		echo "error";
	}
	
	$row=$obj->fetch();
	while($row){
		print_r($row);
		$row=$obj->fetch();
	}*/
	
?>




